'use strict'

const path = require('path')

module.exports = appInfo => {
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1509849515376_3730';

  // add your config here
  config.view = {
    defaultViewEngine: 'nunjucks',
    mapping: {
      '.tpl': 'nunjucks',
    },
  };

  config.security = {
    csrf: false,
    ctoken: false,
  };

  config.mysql = {
    client: {
      host: 'localhost',
      port: '3306',
      user: 'root',
      password: '123',
      database: 'community',
    },
    app: true,
    agent: false,
  };

  config.redis = {
    client: {
      port: 6379,
      host: '127.0.0.1',
      password: null,
      db: 0,
    },
    agent: true,
  };

  config.static = {
    dir: [ path.join(appInfo.baseDir, 'app/public'), path.join(appInfo.baseDir, 'client') ],
  }

  // relate to user: session => locals ect.
  config.middleware = [
    'user',
    'errorHandler',
  ]

  config.errorHandler = {
    match: '/api',
  }

  config.security = {
    domainWhiteList: [ 'http://192.168.0.119:8081' ],
  };

  config.cors = {
    origin: '*',
  };

  return config;
};
